package kneipe;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

public class ActionLog extends JPanel {
	private static final long serialVersionUID = 1L;
	private Kneipe kneipe;
	private JScrollPane scrollPane;
	private JTextArea log;

	public ActionLog() {
		this(null);
	}

	public ActionLog(Kneipe kneipe) {
		this.setKneipe(kneipe);
		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		this.log=new JTextArea();
		initScrollPane();		
		this.log.setEditable(false);
		this.add(scrollPane);
	}

	private void initScrollPane() {
		scrollPane = new JScrollPane(this.log);
		scrollPane.setHorizontalScrollBar(null);
		scrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		scrollPane
				.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
	}

	public Kneipe getKneipe() {
		return kneipe;
	}

	public void setKneipe(Kneipe kneipe) {
		this.kneipe = kneipe;
	}
	
	public void addEntry(String newEntry) {
		this.log.append(newEntry+"\n");
	}

}
